package com.zxy.ziems.server.statistics.controller;

import com.zxy.btp.common.response.JsonResponse;
import com.zxy.ziems.server.statistics.pojo.param.TechnologyParam;
import com.zxy.ziems.server.statistics.service.TechnologyService;
import com.zxy.ziems.server.vo.ChartVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 工艺能耗
 */
@RestController
@RequestMapping("/api/technology")
public class TechnologyController {

    @Autowired
    private TechnologyService technologyService;

    /**
     * 能源分析
     *
     * @param param
     * @return
     */
    @PostMapping("/getEnergy")
    public JsonResponse<ChartVo> getEnergy(@RequestBody @Validated(TechnologyParam.Energy.class) TechnologyParam param) {
        return JsonResponse.SUCCESS(technologyService.getEnergy(param));
    }

    /**
     * 产线分析
     *
     * @param param
     * @return
     */
    @PostMapping("/getProductionLine")
    public JsonResponse<ChartVo> getProductionLine(@RequestBody @Validated(TechnologyParam.ProductionLine.class) TechnologyParam param) {
        return JsonResponse.SUCCESS(technologyService.getProductionLine(param));
    }

    /**
     * 设备分析
     *
     * @param param
     * @return
     */
    @PostMapping("/getDeviceVo")
    public JsonResponse<ChartVo> getDeviceVo(@RequestBody @Validated(TechnologyParam.Device.class) TechnologyParam param) {
        return JsonResponse.SUCCESS(technologyService.getDeviceVo(param));
    }

    /**
     * 单元分析
     *
     * @param param
     * @return
     */
    @PostMapping("/getUnitVo")
    public JsonResponse<ChartVo> getUnitVo(@RequestBody @Validated(TechnologyParam.Unit.class) TechnologyParam param) {
        return JsonResponse.SUCCESS(technologyService.getUnitVo(param));
    }
}
